<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			div{
				height: 200px;
				border: 4px solid red;
			}
		</style>
		<script>
			function doDiv(){
				var dar=document.getElementsByTagName("div");
				for(var i in dar){
					dar[i].onclick=function(){
						alert("This is div");
					}//
				}
			}
		</script>
	</head>
	<body>
		<div></div>
		<div></div>
		<input type="button" value="给Div添加点击事件" onclick="doDiv()"/>
	</body>
</html>
